package com.gmss.crawler.task;

import java.util.concurrent.ThreadFactory;

public class ThreadPoolFactory implements ThreadFactory {
    private String prefix;
    private int counter;

    public ThreadPoolFactory(String prefix) {
        this.prefix = prefix;
        this.counter = 0;
    }

    public Thread newThread(Runnable r) {
        ++this.counter;
        Thread t = new Thread(r, this.prefix + "-Thread-" + this.counter);
        return t;
    }
}
